﻿Imports System.Windows.Forms

Public Class RecordSettingsDialog
    Private Const MS As String = "{0} milliseconds"

    Private pRecordSettings As New Clicknator.RecordSettings

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.GatherSettings()
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Public Property RecordingSettings() As Clicknator.RecordSettings
        Get
            Return pRecordSettings
        End Get
        Set(ByVal value As Clicknator.RecordSettings)
            pRecordSettings = value
        End Set
    End Property

    Private Sub ClickSampleCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles ClickSampleCheckBox.CheckedChanged
        'CursorRateTrackBar.Enabled = Not ClickSampleCheckBox.Checked
        'lblsampleRate.Enabled = Not ClickSampleCheckBox.Checked
    End Sub

    Private Sub CursorRateTrackBar_ValueChanged(sender As Object, e As EventArgs) Handles CursorRateTrackBar.ValueChanged
        lblsampleRate.Text = String.Format(MS, CursorRateTrackBar.Value)
    End Sub

    Private Sub MinimizeWaitTimesCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles MinimizeWaitTimesCheckBox.CheckedChanged
        MinimizedWaitPeriodTrackBar.Enabled = MinimizeWaitTimesCheckBox.Checked
        lblWaitPeriod.Enabled = MinimizeWaitTimesCheckBox.Checked
    End Sub

    Private Sub MinimizedWaitPeriodTrackBar_ValueChanged(sender As Object, e As EventArgs) Handles MinimizedWaitPeriodTrackBar.ValueChanged
        lblWaitPeriod.Text = String.Format(MS, MinimizedWaitPeriodTrackBar.Value)
    End Sub


    Private Sub GatherSettings()
        If AbsoluteRadio.Checked Then
            'Absolute
            pRecordSettings.CursorPosition = Clicknator.RecordSettings.CURSOR_POS_ABSOLUTE
        ElseIf RelativeRadio.Checked Then
            'Relative
            pRecordSettings.CursorPosition = Clicknator.RecordSettings.CURSOR_POS_RELATIVE
        Else
            'Move
            pRecordSettings.CursorPosition = Clicknator.RecordSettings.CURSOR_POS_MOVE
        End If

        'refresh only on click ?
        pRecordSettings.CursorRefreshOnClickOnly = ClickSampleCheckBox.Checked

        'refresh rate
        pRecordSettings.CursorSampleRefreshRate = CursorRateTrackBar.Value

        'minimize time ?
        pRecordSettings.MinimizeWaitTimes = MinimizeWaitTimesCheckBox.Checked

        pRecordSettings.MinimizedWaitPeriod = MinimizedWaitPeriodTrackBar.Value
    End Sub


End Class
